//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "form_ChInprod.h"
#include "DataModule.h"
#include "FormInRep.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TFChInprod *FChInprod;
//---------------------------------------------------------------------------
__fastcall TFChInprod::TFChInprod(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TFChInprod::DBGrid1KeyPress(TObject *Sender, char &Key)
{
 if(Key == 13)
 {
  Key = 0;
        ShowCurr();
 }
 if(Key == 27)
 {
  Close();
 }
 if(Key == '\b')
 {
        DelCurr();
 }
}
//---------------------------------------------------------------------------
void __fastcall TFChInprod::FormCreate(TObject *Sender)
{
 IBQuery1->Open();
}
//---------------------------------------------------------------------------
void __fastcall TFChInprod::FormClose(TObject *Sender,
      TCloseAction &Action)
{
 IBQuery1->Close();
}
//---------------------------------------------------------------------------
void __fastcall TFChInprod::Button3Click(TObject *Sender)
{
        Close();        
}
//---------------------------------------------------------------------------


void __fastcall TFChInprod::DelCurr()
{
        //TODO: Add your source code here
          try
  {
  String ID = IBQuery1IDIN->AsString;
  AskDel->SQL->Text = "update INPRODM set deleted = 1 where IDIN = " + ID;
  IBQuery1->Close();
  AskDel->ExecSQL();
  IBQuery1->Open();
  }
  catch(...)
  {
   if(!IBQuery1->Active)
    IBQuery1->Open();
  }
}
void __fastcall TFChInprod::Button1Click(TObject *Sender)
{
 DelCurr();        
}
//---------------------------------------------------------------------------



void __fastcall TFChInprod::ShowCurr()
{
        //TODO: Add your source code here
          if(!IBQuery1IDIN->IsNull)
  {
   TFRepIncome *f3;
   f3 = new TFRepIncome(NULL);
   f3->IDIN = IBQuery1IDIN->AsString;
   f3->Dt = IBQuery1INDATE->AsString;
   f3->Prepear();
   f3->ShowModal();
   delete f3;
  }
}
void __fastcall TFChInprod::Button2Click(TObject *Sender)
{
 ShowCurr();        
}
//---------------------------------------------------------------------------

void __fastcall TFChInprod::FormMouseWheel(TObject *Sender,
      TShiftState Shift, int WheelDelta, TPoint &MousePos, bool &Handled)
{
        try
        {
                Handled = true;
                if(WheelDelta<0)
                DBGrid1->DataSource->DataSet->Next();
                else
                DBGrid1->DataSource->DataSet->Prior();

        }
        catch(...)
        {
        }
}
//---------------------------------------------------------------------------

